﻿<ResourceDictionary
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

  xmlns:d="clr-namespace:System.Windows.Data;assembly=PresentationFramework"
  xmlns:cm="clr-namespace:System.ComponentModel;assembly=WindowsBase"

  xmlns:controls="clr-namespace:MiniUML.View.Controls;assembly=MiniUML.View"
  xmlns:shapes="clr-namespace:MiniUML.Plugins.UmlClassDiagram.Controls.View.Shapes"
  xmlns:designItem="clr-namespace:MiniUML.View.Views.ResizeAdorner;assembly=MiniUML.View"

  xmlns:connect="clr-namespace:MiniUML.Plugins.UmlClassDiagram.Controls.View.Connect"

  xmlns:conv="clr-namespace:MiniUML.Plugins.UmlClassDiagram.Converter"
  xmlns:viewconv="clr-namespace:MiniUML.View.Converter;assembly=MiniUML.View"
  >
  <ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="/MiniUML.Plugins.UmlClassDiagram;component/Themes/Brushes.xaml"  />
    <ResourceDictionary Source="/MiniUML.Plugins.UmlClassDiagram;component/Themes/UmlTextBox.xaml"  />
  </ResourceDictionary.MergedDictionaries>

  <Style x:Key="Note" TargetType="Path" BasedOn="{StaticResource PathItemStyle}">
    <Setter Property="Data">
      <Setter.Value>
        <PathGeometry>
          <PathGeometry.Figures>
            <PathFigureCollection>
              <PathFigure IsClosed="True" StartPoint="0,0">
                <PathFigure.Segments>
                  <PathSegmentCollection>
                    <LineSegment Point="99,0" />
                    <LineSegment Point="99,59" />
                    <LineSegment Point="0,59" />
                  </PathSegmentCollection>
                </PathFigure.Segments>
              </PathFigure>
            </PathFigureCollection>
          </PathGeometry.Figures>
        </PathGeometry>
      </Setter.Value>
    </Setter>
  </Style>

  <!-- Default style for comment shape -->
  <Style TargetType="{x:Type shapes:UmlCommentShape}">
    <Setter Property="SnapsToDevicePixels" Value="True"/>
    <Setter Property="Width" Value="{Binding Width}" />
    <Setter Property="Height" Value="{Binding Height}" />
    <Setter Property="ToolTip" Value="Note" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type shapes:UmlCommentShape}">

          <designItem:DesignerItem IsSelected="{Binding Path=IsSelected}"
                                   ResizeSelectedShapes="{Binding ResizeSelectedShapesCommand}"
                                   Background="{x:Null}" ><!-- Background=null makes inner part hittest invisible -->
            <designItem:DesignerItem.Content>

              <Border Background="{TemplateBinding Property=Background}"
                  BorderBrush="{TemplateBinding Property=BorderBrush}"
                  BorderThickness="{TemplateBinding Property=BorderThickness}" 
              >
            <!-- This margin is here to let users drag the element since its only the textbox otherwise -->
            <Grid Margin="9,9,3,3">
              <Path Style="{StaticResource Note}"
                    Margin="0"
                    HorizontalAlignment="Stretch"
                    VerticalAlignment="Stretch"/>

              <!-- White Overlay -->
              <Path Fill="White" Stroke="White" Margin="0" HorizontalAlignment="Right" VerticalAlignment="Top">
                <Path.Data>
                  <PathGeometry>
                    <PathGeometry.Figures>
                      <PathFigureCollection>
                        <PathFigure IsClosed="True" StartPoint="85,-5">
                          <PathFigure.Segments>
                            <PathSegmentCollection>
                              <LineSegment Point="105,-5" />
                              <LineSegment Point="105,19" />
                              <LineSegment Point="85,19" />
                            </PathSegmentCollection>
                          </PathFigure.Segments>
                        </PathFigure>
                      </PathFigureCollection>
                    </PathGeometry.Figures>
                  </PathGeometry>
                </Path.Data>
              </Path>

              <!-- Black Overlay -->
              <Path Stroke="Black" Margin="0" HorizontalAlignment="Right" VerticalAlignment="Top">
                <Path.Data>
                  <PathGeometry>
                    <PathGeometry.Figures>
                      <PathFigureCollection>
                        <PathFigure IsClosed="True" StartPoint="80,1">
                          <PathFigure.Segments>
                            <PathSegmentCollection>
                              <LineSegment Point="99,19" />
                              <LineSegment Point="80,19" />
                            </PathSegmentCollection>
                          </PathFigure.Segments>
                        </PathFigure>
                      </PathFigureCollection>
                    </PathGeometry.Figures>
                  </PathGeometry>
                </Path.Data>
              </Path>

              <TextBox BorderThickness="0"
                       Background="Transparent"
                       Foreground="Black"
                       IsTabStop="False"
                       Style="{StaticResource UmlTextBox}"
                       Text="{Binding Path=Text}"
                       AcceptsReturn="True"
                       TextWrapping="WrapWithOverflow"
                       Margin="5,5,21,5"
                   />
            </Grid>
          </Border>

            </designItem:DesignerItem.Content>
          </designItem:DesignerItem>

          <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
              <Setter Property="Cursor" Value="Hand"/>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

</ResourceDictionary>
